package org.duoyi.striver.consts;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.duoyi.striver.service.Task;
import org.duoyi.striver.service.task.*;

@Getter
@AllArgsConstructor
public enum TaskEnum {

    伙伴任务(BuddyTask.class),
    自动挖宝(DigTreasureTask.class),
    竞技任务(SportsTask.class),
    宝图任务(TreasureTask.class),
    英雄试炼(TrialTask.class),

    ;

    private final Class<? extends Task> taskClass;

    public static TaskEnum getByClass(Class<? extends Task> taskClass) {
        for (TaskEnum task : values()) {
            if (task.taskClass.equals(taskClass)) {
                return task;
            }
        }
        throw new RuntimeException("找不到类【" + taskClass.getName() + "】的对应任务");
    }
}
